//
//  MyWalletm.m
//  EcmDoctor
//
//  Created by Mac on 16/2/23.
//  Copyright © 2016年 张进. All rights reserved.
//

#import "MyWalletm.h"
#import "NetWorkUtil.h"
#import <SSKeychain/SSKeychain.h>
#import "AppUtils.h"
@implementation MyWalletm
+(void)requetDoctorWalletWith:(NSString *)doctorInfoId And:(NSString *)month success:(void (^)(NSArray *))success failure:(void (^)(NSError *))failure
{
    NetWorkBaseRequest *req = [[NetWorkBaseRequest alloc] init];
    //请求参数
    
    req.moduleName = @"DoctorRS";
    req.methodName = @"getAllDoctorMoneyByMonth";
    [req setValue:doctorInfoId forKey:@"doctor_id"];
    [req setValue:month forKey:@"month"];

    [NetWorkUtil requestWithPOST:req success:^(NetWorkBaseResponse *responseObject) {
        NSError *error = nil;
        
        if (responseObject.code.integerValue == 1) {
            if (!responseObject.data) {
                success(nil);
                return;
            }
            NSLog(@"----------%@",responseObject);
            NSData *data = [responseObject.data dataUsingEncoding:NSUTF8StringEncoding];
            NSArray *userAttrs = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
            
            if (error) {
                failure(error);
                return;
            }
          

            NSMutableArray *ary=[NSMutableArray array];
            for(int i=0;i<userAttrs.count;i++)
            {
                MyWalletm *mywallet=[[MyWalletm alloc]initWithDictionary:userAttrs[i]];
                [ary addObject:mywallet];
                
            }
            success(ary);
            
        }
        else{
            error = [NSError errorWithDomain:responseObject.msg code:responseObject.code.integerValue userInfo:nil];
            failure(error);
        }
        
    } failure:^(NSError *error) {
        failure(error);
        
    } cache:NO];

}
@end
